﻿using ReNameEx.Model;
using ReNameEx.SubPage;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

using Wpf.Ui.Controls;

namespace ReNameEx
{
    /// <summary>
    /// EditRule.xaml 的交互逻辑
    /// </summary>
    public partial class EditRule : FluentWindow
    {
        RulePage? _CurRulePage;

        public ReExRuleBase Result { get; set; }

        public EditRule()
        {
            InitializeComponent();
        }

        private void FluentWindow_Loaded(object sender, RoutedEventArgs e)
        {
            RuleNavigation.Navigate(typeof(InsertRulePage));
        }

        private void BtnSaveRule_Click(object sender, RoutedEventArgs e)
        {
            if (_CurRulePage != null)
            {
                Result = _CurRulePage.GetConfig();
                Result.IgnoreCase = ShowIgnoreCase.IsChecked ?? false;
                Result.IgnoreExtension = ShowIgnoreExtension.IsChecked ?? false;
                Result.ReverseOrder = ShowReverseOrder.IsChecked ?? false;
                Close();
            }
        }

        private void RuleNavigation_Navigated(NavigationView sender, NavigatedEventArgs args)
        {
            _CurRulePage = args.Page as RulePage;
            if (_CurRulePage != null)
            {
                ShowIgnoreCase.Visibility = _CurRulePage.ShowIgnoreCase ? Visibility.Visible : Visibility.Collapsed;
                ShowIgnoreExtension.Visibility = _CurRulePage.ShowIgnoreExtension ? Visibility.Visible : Visibility.Collapsed;
                ShowReverseOrder.Visibility = _CurRulePage.ShowReverseOrder ? Visibility.Visible : Visibility.Collapsed;
            }
        }
    }
}
